﻿<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="App=Equipment.Business.Application" %>
<%@ Import Namespace="Equipment.DataAccess" %>
<%@ Import Namespace="Equipment.Business" %>
<span id="woPager" class="pager right">
    <form>
    <img src="../../Content/addons/pager/icons/first.png" class="first" />
    <img src="../../Content/addons/pager/icons/prev.png" class="prev" />
    <input type="text" style="width: 40px" class="pagedisplay" />
    <img src="../../Content/addons/pager/icons/next.png" class="next" />
    <img src="../../Content/addons/pager/icons/last.png" class="last" />
    <select class="pagesize">
        <option selected="selected" value="10">10</option>
        <option value="20">20</option>
        <option value="30">30</option>
        <option value="40">40</option>
    </select>
    </form>
</span>
<table id="woTable" class="data-table">
    <thead>
        <tr>
            <th colspan = "2">
                Action
            </th>
            <th>
                Status
            </th>
            <th>
                Work Order Type
            </th>
            <th>
                Description
            </th>
            <th>
                Date Opened
            </th>
            <th>
                Date Due
            </th>
            <th>
                Assign To
            </th>
        </tr>
    </thead>
    <tbody>
        <% For Each item As WorkOrder In ViewData("WorkOrderList")%>
        <tr>
           <td>
                <% If App.CurrentUserInfo.HasPermissionFor(PageType.EditWorkOrder) Then%>
                <% If item.Status = WorkOrderStatusType.Complete Then %>
                <%: Html.ActionLink("View", "Edit", New With {.id = item.ID})%>
                   <%  Else%>
                   <%: Html.ActionLink("Edit", "Edit", New With {.id = item.ID})%>
                    <% End If%>
                <%  End If %>
                
            </td>
            <td>
                <% If App.CurrentUserInfo.HasPermissionFor(PageType.ProcessWorkOrder) AndAlso item.Status <> WorkOrderStatusType.Complete Then%>
                    <%: Html.ActionLink("Process", "Process", New With {.id = item.ID})%>
                <%  End If %>
            </td>
            <td>
                <%= WorkOrderStatus.GetDescriptionByType(item.Status)%>
            </td>
            <td>
                <%= RequirementTypeLookup.GetDescriptionByType(item.RequirementType)%>
            </td>
            <td>
                <%: item.Description%>
            </td>
            <td>
                <%: TimeZoneManager.ConvertToUserTimeStringFor(item.DateOpened)%>
            </td>
            <td>
                <%: TimeZoneManager.ConvertToUserTimeStringFor(item.DateDue)%>
            </td>
            <td>
                <%= String.Join(", ", item.Groups.Select(Function(g) g.Description))%>
            </td>
        </tr>
        <% Next%>
    </tbody>
</table>
